package br.com.iswe.gwt.ui.client;

import br.com.iswe.gwt.ui.client.img.CommonImageBundle;

import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ButtonBase;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;

public class PnBotoesDetail extends FlexTable {
	
	private static final String PN_BOTOES_DETAIL = "pnBotoesDetail";

	public ButtonBase btoFechar;
	
	public HorizontalPanel botoesSuperior;
	
	
	public PnBotoesDetail(Widget titulo, Widget adicionar, ClickListener listenerFechar){
		setWidth("100%");
		
		setStyleName(PN_BOTOES_DETAIL);
		
		CommonImageBundle commonImageBundle = ISWEImageFactory.getCommonImageBundle();
		
		//Titulo
		AbstractImagePrototype iconePtp = commonImageBundle.iconeTopico01();
		setWidget(0, 0, iconePtp.createImage());
		
		setWidget(0, 1, titulo);
		getFlexCellFormatter().setAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
		
		botoesSuperior = new HorizontalPanel();
		setWidget(0, 2, botoesSuperior);
		botoesSuperior.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
		botoesSuperior.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
		getFlexCellFormatter().setAlignment(0, 2, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_MIDDLE);
		//Adicionar
		setWidget(0, 3, adicionar);
		getFlexCellFormatter().setAlignment(0, 3, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_MIDDLE);
		//Fechar
		AbstractImagePrototype fecharPtp = commonImageBundle.iconeXFechar();
		btoFechar = new Button(fecharPtp.getHTML());
		btoFechar.setStyleName("btoFechar");
		btoFechar.addClickListener(listenerFechar);
		setWidget(0, 4, btoFechar);
		getFlexCellFormatter().setAlignment(0, 4, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_MIDDLE);
		//getFlexCellFormatter().setWidth(0, 4, "5%");
	}
	
	
}
